package com.oil.petro.eshop.utils;

import com.oil.petro.eshop.bean.BasicBean;
import com.oil.petro.eshop.service.UserAccountService;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.ui.Model;

public class NavigationBar {

    public void getNavigationBarDataModel(Map<String, Object> model, BasicBean basicBean, UserAccountService accountService) {

        if (basicBean.getUser() != null && !basicBean.getUser().equals("")) {
            int status = accountService.getAccountStatus(basicBean.getUser());
            model.put("status", status);
            basicBean.setAvailableUser(true);
            model.put("status", status);
            basicBean.setOrderCounter(accountService.getNumberProductsInCart(basicBean.getUser()));
        }
        model.put("commandBean", basicBean);

    }

    public void getNavigationBarDataModel(Model model, BasicBean basicBean, UserAccountService accountService) {

        if (basicBean.getUser() != null && !basicBean.getUser().equals("")) {
            int status = accountService.getAccountStatus(basicBean.getUser());
            model.addAttribute("status", status);
            basicBean.setAvailableUser(true);
            model.addAttribute("status", status);
            basicBean.setOrderCounter(accountService.getNumberProductsInCart(basicBean.getUser()));
        }
        model.addAttribute("commandBean", basicBean);

    }

}
